class CreateDidiliesTrails < ActiveRecord::Migration
    def self.up
        create_table "didilies_trails", :id => false, :force => true do |t|
            t.column "trail_id", :int
            t.column "didily_id", :int
        
        end    
        
            add_index :didilies_trails, :didily_id
            add_index :didilies_trails, :trail_id            
            
            execute "ALTER TABLE didilies_trails ADD CONSTRAINT didilies_trails_trail_id_fkey FOREIGN KEY (trail_id) REFERENCES trails (id) ON DELETE CASCADE ON UPDATE CASCADE"
            execute "ALTER TABLE didilies_trails ADD CONSTRAINT didilies_trails_didily_id_fkey FOREIGN KEY (didily_id) REFERENCES didilies (id) ON DELETE CASCADE ON UPDATE CASCADE"           
    end
    
    def self.down
        drop_table "didilies_trails"
    end
end
